package com.igeekhome.dao;

import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.igeekhome.pojo.CustomerService;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.Wrapper;

/**
 * <p>
 * 客服表 Mapper 接口
 * </p>
 *
 * @author ${author}
 * @since 2021-03-16
 */
public interface CustomerServiceMapper extends BaseMapper<CustomerService> {

    //从数据库查询总会话量
    @Select("select sum(sessionCount) from customer_service")
    int sessioncount(@Param(Constants.WRAPPER) Wrapper wrapper);
    //从数据库查询处理中的会话数量
    @Select("SELECT SUM(totalSessionCount-totalEndSessionCount) FROM workload_statistics")
    int session_processing(@Param(Constants.WRAPPER) Wrapper wrapper);
    //从数据库查询在线客服数
    @Select("SELECT COUNT(state) FROM customer_service WHERE state='在线'")
    int cs_onlinecount(@Param(Constants.WRAPPER) Wrapper wrapper);
    //从数据库查询查询今日消息数
    @Select("SELECT SUM(totalMessageCount) FROM workload_statistics")
    int totalMessageCount(@Param(Constants.WRAPPER) Wrapper wrapper);
}
